<template>
  <div class="bc" v-bind:style="{'height':clientHeight + 'px'}">
    <devList showDefault="no" @showDev="showDev" @changeChild="changeChild" closed="false"></devList>
    <Taost
      v-show="show"
      @closeToast="closeToast"
    ></Taost>
    <div @click="$router.back(-1)" class="input-button blue">返 回</div>
  </div>
</template>

<script>
import devList from '../../components/common/select'
import Taost from '../../components/common/Taost'
import { Toast, Confirm } from 'vue-ydui/dist/lib.rem/dialog'
import {ALLOTFLOW} from '../../api/request'

export default {
  name: 'distribute',
  components: {devList, Taost},
  data () {
    return {
      clientHeight: document.documentElement.clientHeight,
      show: false,
      placeCode: '',
      flow: ''
    }
  },
  methods: {
    showDev: function (code, name) {
      this.show = true
      this.placeCode = code
    },
    changeChild: function (p) {
    },
    closeToast: function (flow) {
      Confirm({
        mes: '确定分配流量？',
        opts: () => {
          this.show = false
          ALLOTFLOW(this.$store.getters.uid, this.placeCode, flow).then(res => {
            console.log(res)
            if (res.data.code === 200) {
              Toast({mes: '分配成功', timeout: 1000})
              this.$router.go(-1)
            } else {
              this.flow = ''
              Toast({mes: res.data.msg, timeout: 1000})
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped>
  .bc{
    width: 100%;
    background-color: #eff0f1;
    padding-top: 0.2rem;
  }
  .blue{
    margin-top: 5.6rem;
    box-shadow: 0 0 0.2rem 0.1rem rgba(194, 198, 199, 0.1);
    border-radius: 0.1rem;
    background-color: #0092f8;
  }
</style>
